/**
 * 
 */
package com.gragra.applications;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
 * @author Christoph Teichmann
 * 02.10.2013
 */
public class SplitBenchmark
{
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException
	{
		String prefix = args[0];
		BufferedReader in = new BufferedReader(new FileReader(args[1]));
		String line;
		BufferedWriter bw = null;
		Integer add = 0;
		while((line = in.readLine()) != null)
		{
			line = line.trim();
			if(line.equals(""))
			{continue;}
			if(line.matches("( *\\d+\\|\\d+ *)+"))
			{
				if(bw != null)
				{bw.close();}
				String p = prefix + "_" + add.toString();
				++add;
				bw = new BufferedWriter(new FileWriter(p+".txt"));
				bw.write(line);
			}
			else
			{
				bw.write("\r\n");
				bw.write(line);
			}
		}
		if(bw != null)
		{bw.close();}
		in.close();
	}
}